<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\ModelForm;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Layout\Content;
use App\Models\ReceivingAddres;

class ReceivingAddresController extends Controller
{
    use ModelForm;
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header('收货地址');
            $content->description('管理');
            $content->body($this->grid());
        });
    }

    public function edit($id)
    {
        return Admin::content(function (Content $content) use ($id) {
            $content->header('收货地址');
            $content->description('编辑');

            $content->body($this->form()->edit($id));
        });
    }

    public function create()
    {
        return Admin::content(function (Content $content) {
            $content->header('收货地址');
            $content->description('创建');

            $content->body($this->form());
        });
    }

    protected function grid()
    {
        return Admin::grid(ReceivingAddres::class, function (Grid $grid) {
            // $grid->position_tags('轮播图序号');
            $grid->id('序号');
            $grid->user_id('填地址者id',11);
            $grid->name('收货人姓名',255);
            $grid->phone_number('收货手机号',255);
            $grid->email('常用邮箱',255);
            $grid->region('送货地区',255);
            $grid->detailed_address('详细地址',255);
            // 导入 导出  S
            // $grid->disableFilter();
            // $grid->disableExport();
            // 导入 导出  E
            // $grid->disableCreateButton();
            // $grid->disablePagination();
            // $grid->disableFilter();
            $grid->disableFilter();
            $grid->disableExport();
            // $grid->disableCreateButton();
            // $grid->disablePagination();
            $grid->disableFilter();
            $grid->paginate(10);
            $grid->perPages([10,20,30]);
            $grid->disableRowSelector();
            $grid->disableCreateButton();
            $grid->disableActions();
            $grid->actions(function ($actions) {
                // $actions->disableDelete();
                $actions->disableDelete();
            });
        });
    }

    protected function form()
    {
        return Admin::form(ReceivingAddres::class, function (Form $form) {
            // $form->text('position_tags', '轮播图位置');
            $form->text('user_id', '填地址者id');
            $form->text('name', '收货人姓名');
            $form->text('phone_number', '收货手机号');
            $form->text('email', '常用邮箱');
            $form->text('region', '送货地区');
            $form->text('detailed_address', '详细地址');
        });
    }
    }
